//
// @functions
//


// STRIP UNIT
// It strips the unit of measure and returns it
@function strip-unit($num) {
  @return $num / ($num * 0 + 1);
}

// CONVERT TO UNITS
@function convert-to-units($value, $unit: rem, $base-value: $font-size-base) {
  $result: strip-unit($value) / strip-unit($base-value);
  @if ($result != 0) {
    @return $result * 1#{$unit};
  }
  @return $result;
}

// UNITS CALC

// New Syntax, allows to optionally calculate on a different base value to counter compounding effect of rem's.
// Call with 1, 2, 3 or 4 parameters, 'px' is not required but supported:
//
//   rem-calc(10 20 30px 40);
//
// Space delimited, if you want to delimit using comma's, wrap it in another pair of brackets
//
//   rem-calc((10, 20, 30, 40px));
//
// Optionally call with a different base (eg: 8px) to calculate rem.
//
//   rem-calc(16px 32px 48px, 8px);
//
// If you require to comma separate your list
//
//   rem-calc((16px, 32px, 48), 8px);

@function units-calc($values, $unit: rem, $base-value: $font-size-base) {
  $max: length($values);

  @if $max == 1 { @return convert-to-units($values, $unit, $base-value)}

  $calcValues: ();
  @for $i from 1 through $max {
    $calcValues: append($calcValues, convert-to-units(nth($values, $i), $unit, $base-value));
  }
  @return $calcValues;
}

@function em-calc($values, $base-value: $font-size-base) {
  @return units-calc($values, em, $base-value);
}

@function rem-calc($values, $base-value: $font-size-base) {
  @return units-calc($values, rem, $base-value);
}

@function get-breakpoint($name) {
  $point: map-get($points, $name);
  @return $point;
}
